home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.db.net;
-
- import java.io.DataInputStream;
- import java.io.DataOutputStream;
- import java.io.IOException;
- import symjava.sql.Date;
- import symjava.sql.SQLException;
- import symjava.sql.Time;
- import symjava.sql.Timestamp;
-
- class NetTimestamp extends DateTimeField {
- Timestamp _tsVal;
-
- int getType() {
- return 77;
- }
-
- void readData(DataInputStream is) throws SQLException, IOException, ErrorException {
- int iYear = 0;
- ServerObject obj = (ServerObject)NetClass.getNextObject(is);
- if (obj.getType() == 51) {
- iYear = ((NetData)obj).getInt();
- } else {
- ((ServerObject)this).onObjectError(obj);
- }
-
- int iMonth = 0;
- obj = (ServerObject)NetClass.getNextObject(is);
- if (obj.getType() == 51) {
- iMonth = ((NetData)obj).getInt();
- } else {
- ((ServerObject)this).onObjectError(obj);
- }
-
- int iDay = 0;
- obj = (ServerObject)NetClass.getNextObject(is);
- if (obj.getType() == 51) {
- iDay = ((NetData)obj).getInt();
- } else {
- ((ServerObject)this).onObjectError(obj);
- }
-
- int iHour = 0;
- obj = (ServerObject)NetClass.getNextObject(is);
- if (obj.getType() == 51) {
- iHour = ((NetData)obj).getInt();
- } else {
- ((ServerObject)this).onObjectError(obj);
- }
-
- int iMinutes = 0;
- obj = (ServerObject)NetClass.getNextObject(is);
- if (obj.getType() == 51) {
- iMinutes = ((NetData)obj).getInt();
- } else {
- ((ServerObject)this).onObjectError(obj);
- }
-
- int iSeconds = 0;
- obj = (ServerObject)NetClass.getNextObject(is);
- if (obj.getType() == 51) {
- iSeconds = ((NetData)obj).getInt();
- } else {
- ((ServerObject)this).onObjectError(obj);
- }
-
- int iNanoSeconds = 0;
- obj = (ServerObject)NetClass.getNextObject(is);
- if (obj.getType() == 51) {
- iNanoSeconds = ((NetData)obj).getInt();
- } else {
- ((ServerObject)this).onObjectError(obj);
- }
-
- if (!super._null) {
- try {
- this._tsVal = new Timestamp(iYear, iMonth - 1, iDay, iHour, iMinutes, iSeconds, iNanoSeconds);
- } catch (IllegalArgumentException var10) {
- this._tsVal = null;
- }
- } else {
- this._tsVal = null;
- }
- }
-
- void writeData(DataOutputStream os) throws IOException {
- NetData data = new NetData((short)this._tsVal.getYear());
- data.write(os);
- data = new NetData((short)this._tsVal.getMonth());
- data.write(os);
- data = new NetData((short)this._tsVal.getDate());
- data.write(os);
- data = new NetData((short)this._tsVal.getHours());
- data.write(os);
- data = new NetData((short)this._tsVal.getMinutes());
- data.write(os);
- data = new NetData((short)this._tsVal.getSeconds());
- data.write(os);
- data = new NetData((short)this._tsVal.getNanos());
- data.write(os);
- }
-
- public String getString() throws SQLException {
- return ((Field)this).isNull() ? null : this._tsVal.toString();
- }
-
- public Date getDate() throws SQLException {
- return ((Field)this).isNull() ? null : new Date(this._tsVal.getYear(), this._tsVal.getMonth(), this._tsVal.getDate());
- }
-
- public Time getTime() throws SQLException {
- return ((Field)this).isNull() ? null : new Time(this._tsVal.getHours(), this._tsVal.getMinutes(), this._tsVal.getSeconds());
- }
-
- public Timestamp getTimestamp() throws SQLException {
- return ((Field)this).isNull() ? null : this._tsVal;
- }
-
- public int getSQLType() {
- return 93;
- }
-
- public Object getObject() throws SQLException {
- return new Timestamp(this._tsVal.getYear(), this._tsVal.getMonth(), this._tsVal.getDate(), this._tsVal.getHours(), this._tsVal.getMinutes(), this._tsVal.getSeconds(), this._tsVal.getNanos());
- }
-
- public void setObject(Object obj) throws SQLException {
- this.setTimestamp((Timestamp)obj);
- }
-
- public void setString(String x) throws SQLException {
- this._tsVal = Timestamp.valueOf(x);
- super._null = false;
- }
-
- public void setTimestamp(Timestamp x) throws SQLException {
- this._tsVal = x;
- super._null = false;
- }
- }
-